package controller;

import dao.ArauditorDetailsDao;
import dao.userDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/index")
public class index {
    @Autowired
    public userDao userDao;
    @Autowired
    public ArauditorDetailsDao arauditorDetailsDao;
    //首页展示信息
    @RequestMapping("/showindex")
    public String indexs(HttpServletRequest request){
        //统计在本店记录的总人数
        int totaluser=userDao.totalUser();
        //统计今日销售
        int nowNum;
       String k =arauditorDetailsDao.nowNum();
       if(k==null){
           nowNum=0;
       }else{
           nowNum=(Integer.parseInt(k));
       }
        //统计今日的收入
        double price;
        String p=arauditorDetailsDao.nowTotal();
        if(p==null){
            price=0.00;
        }else{
            price=Double.parseDouble(p);
        }
        //查询本月的收入
        double yueprice =arauditorDetailsDao.yueTotal();
        request.setAttribute("yueprice",yueprice);
        request.setAttribute("price",price);
        request.setAttribute("nowNum",nowNum);
        request.setAttribute("totaluser",totaluser);
        return "Syindex.jsp";
    }
}
